package esiag.pds.Test;

import java.io.Serializable;
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.List;

import javolution.util.FastList;

import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;

import esiag.pds.beans.Information;
import esiag.pds.beans.Parameters;
import esiag.pds.contextManagement.Context;
import esiag.pds.contextManagement.ContextManager;
import esiag.pds.servers.RMIServer;

public class SameContext {
	
	 public static void prepareContext(Context context) {
			FastList<Serializable>l0=new FastList();//<>();
			l0.add(new Information());
			l0.add(new Information());
			context.addList(l0);
			
			FastList<Serializable>l1=new FastList();
			l1.add(new Information());
			l1.add(new Information());
			l1.add(new Information());
			
			context.addList(l1);
			
			FastList<Serializable>l2=new FastList();
			l2.add(new Information());
			l2.add(new Information());
			l2.add(new Information());
			l2.add(new Information());
			context.addList(l2);
			
			FastList<Serializable>l3=new FastList();
			l3.add(new Information());
			l3.add(new Information());
			l3.add(new Information());
			l3.add(new Information());
			context.addList(l3);
		}

	public static void main(String[] args) {
		try {
			 XmlBeanFactory factory=new XmlBeanFactory(new ClassPathResource("Parameters.xml"));
			 Parameters param=factory.getBean("parameters",Parameters.class);
			 
			Context c=new Context();
			prepareContext(c);
			ContextManager cm=new ContextManager(param);
			cm.setContext(c);
			
			RMIServer server =new RMIServer(param.getPort());

			server.rebind(cm);	
				
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}	
	}
}
